<!--
 * @description  : 报表-统计
 * @descriptionDetail : 报表-许可证办理统计/队伍建设统计表/12313统计表
 * @author       : zx
 * @create       : 2024-10-08 00:00:00
-->
<template>
  <view class="page">
    <!-- #ifdef H5-ONLY -->
    <theme-navbar :is-white="false" :title="titleTJ" :custom-back="goBack" style="z-index: 99999" />
    <!-- #endif -->
    <view class="u-table-wrap">
      <u-table>
        <u-tr>
          <u-th style="width: max-content;padding: 0;" v-for="(item,index)  in statisticsColumn" :key="index">

            <u-th v-if="item.list" :class="index==0?'col-th':'col-th1'">{{item.name}}</u-th>
            <u-th v-else>{{item.name}}</u-th>
            <u-tr v-if="item.list">
              <u-th v-for="(cell,j)  in item.list" :key="j" class="row-th">{{cell.name}}</u-th>
            </u-tr>

          </u-th>
        </u-tr>
        <!-- 许可证办理统计 -->
        <template v-if="whosType=='lic_handle_count_hb'">
          <u-tr v-for="(item,index) in newList" :key="index">
            <u-td>{{item.orgName}}</u-td>
            <u-td>{{item.total}}</u-td>
            <u-td>{{item.registerNum}}</u-td>
            <u-td>{{item.extendNum}}</u-td>
            <u-td>{{item.changeNum}}</u-td>
            <u-td>{{item.reissueNum}}</u-td>
            <u-td>{{item.suspendNum}}</u-td>
            <u-td>{{item.resumeNum}}</u-td>
            <u-td>{{item.closeNum}}</u-td>
          </u-tr>
        </template>
        <!-- 队伍建设统计表 -->
        <template v-if="whosType=='LIC_TEAM_BUILDING_STATISTICS'">
          <u-tr v-for="(item,index) in newListTeambuild" :key="index">
            <u-td>{{item.orgName}}</u-td>
            <u-td>{{item.total}}</u-td>
            <!-- 基本情况 -->
            <u-td>{{item.zmPersNum}}</u-td>
            <u-td>{{item.averageAge}}</u-td>
            <u-td>{{item.bureauLeadersNum}}</u-td>
            <u-td>{{item.departmentPersNum}}</u-td>
            <u-td>{{item.ondutyNotOnduty}}</u-td>
            <!-- 对所情况 -->
            <u-td>{{item.teamPersNum}}</u-td>
            <u-td>{{item.teamOnDutyAverageAge}}</u-td>
            <u-td>{{item.holdingInspectionCertificateNum}}</u-td>
            <u-td>{{item.teamNum}}</u-td>
            <!-- 人员学历情况统计 -->
            <u-td>{{item.fulltimePostgraduate}}</u-td>
            <u-td>{{item.postgraduate}}</u-td>
            <u-td>{{item.fulltimeUndergraduate}}</u-td>
            <u-td>{{item.undergraduate}}</u-td>
            <u-td>{{item.juniorCollege}}</u-td>
            <u-td>{{item.highSchool}}</u-td>
            <u-td>{{item.juniorHighSchool}}</u-td>
            <!-- 专卖技能证书持证情况 -->
            <u-td>{{item.oneLevel}}</u-td>
            <u-td>{{item.twoLevel}}</u-td>
            <u-td>{{item.threeLevel}}</u-td>
            <u-td>{{item.fourLevel}}</u-td>
            <u-td>{{item.fiveLevel}}</u-td>
            <!-- -- -->
            <u-td>{{item.jurisdictionPopulation}}</u-td>
            <u-td>{{item.teamJurisdictionPopulation}}</u-td>
            <u-td>{{item.jurisdictionCertifiedAccountTotal}}</u-td>
            <u-td>{{item.teamJurisdictionAveragePopulation}}</u-td>
            <u-td>{{item.bodyCameraNum}}</u-td>
          </u-tr>
        </template>
        <!-- 12313统计表 -->
        <template v-if="whosType=='LIC_12313_STATISTICS'">
          <u-tr v-for="(item,index) in newList12313" :key="index">
            <u-td>{{item.orgName}}</u-td>
            <!-- <u-td>{{item.total}}</u-td> -->
            <!-- 专卖 -->
            <u-td>{{item.governmentalPolicy}}</u-td>
            <u-td>{{item.licenseConsultation}}</u-td>
            <u-td>{{item.truefalseIdentification}}</u-td>
            <u-td>{{item.electronic}}</u-td>
            <!-- 营销 -->
            <u-td>{{item.licComplaints}}</u-td>
            <u-td>{{item.authenticCigarettesComplaints}}</u-td>
            <u-td>{{item.protectionOfMinors}}</u-td>
            <u-td>{{item.complaints}}</u-td>
            <u-td>{{item.cigaretteOrdering}}</u-td>
            <u-td>{{item.customerBasicInformation}}</u-td>
            <u-td>{{item.supplyOfGoods}}</u-td>
            <u-td>{{item.terminalConstruction}}</u-td>
            <u-td>{{item.settlementService}}</u-td>
            <u-td>{{item.cigarettePrices}}</u-td>
            <u-td>{{item.businessComplaints}}</u-td>
            <!-- 物流 -->
            <u-td>{{item.logisticsDelivery}}</u-td>
            <u-td>{{item.logisticsComplaints}}</u-td>
            <!-- 工业 -->
            <u-td>{{item.cigaretteQuality}}</u-td>
          </u-tr>
        </template>
        
      </u-table>
      <view v-if="whosType=='LIC_12313_STATISTICS'&&newList12313.length==0" class="no-data">
        ~ 暂无数据 ~
      </view>
      <view v-if="whosType=='LIC_TEAM_BUILDING_STATISTICS'&&newListTeambuild.length==0" class="no-data">
        ~ 暂无数据 ~
      </view>
      <view v-if="whosType=='lic_handle_count_hb'&&newList.length==0" class="no-data">
        ~ 暂无数据 ~
      </view>
    </view>
  </view>
</template>
<script>
import reportService from "@/service/report/report.service";
import mescrollList from "@/components/mescroll_list.vue";

export default {
  components: { mescrollList },
  data() {
    return {
      handleProc: "",
      param: {},
      newList: [],
      newListTeambuild: [],
      newList12313: [],
      titleTJ: "",
      whosType: "",
      statisticsColumn: [],
      statisticsColumnLicence: [
        { name: "所属单位", keys: "orgName" },
        { name: "总数", keys: "total" },
        { name: "新办", keys: "registerNum" },
        { name: "延续", keys: "extendNum" },
        { name: "变更", keys: "changeNum" },
        { name: "补办", keys: "reissueNum" },
        { name: "停业", keys: "suspendNum" },
        { name: "恢复营业", keys: "resumeNum" },
        { name: "歇业", keys: "closeNum" }
      ],
      statisticsColumnTeambuild: [
        { name: "所属单位", keys: "orgName" },
        { name: "总数", keys: "total" },
        {
          name: "基本情况",
          list: [
            { name: "专卖人员数量", keys: "zmPersNum" },
            { name: "平均年龄", keys: "averageAge" },
            { name: "局领导人数", keys: "bureauLeadersNum" },
            { name: "科室人员人数", keys: "departmentPersNum" },
            { name: "在编不在岗", keys: "ondutyNotOnduty" }
          ]
        },

        {
          name: "对所情况",
          list: [
            { name: "对所人数", keys: "teamPersNum" },
            { name: "对所在岗人员平均年龄", keys: "teamOnDutyAverageAge" },
            { name: "持有检查证人数", keys: "holdingInspectionCertificateNum" },
            //  { name:"对所编制" ,keys:'total'},
            { name: "对所数量", keys: "teamNum" }
          ]
        },
        {
          name: "人员学历情况统计",
          list: [
            { name: "全日制研究生学历", keys: "fulltimePostgraduate" },
            { name: "研究生学历", keys: "postgraduate" },
            { name: "全日制大学本科学历", keys: "fulltimeUndergraduate" },
            { name: "大学本科学历", keys: "undergraduate" },
            { name: "大专学历", keys: "juniorCollege" },
            { name: "高中/中专学历", keys: "highSchool" },
            { name: "初中及以下学历", keys: "juniorHighSchool" }
          ]
        },
        {
          name: "专卖技能证书持证情况",
          list: [
            { name: "一级", keys: "oneLevel" },
            { name: "二级", keys: "twoLevel" },
            { name: "三级", keys: "threeLevel" },
            { name: "四级", keys: "fourLevel" },
            { name: "五级", keys: "fiveLevel" }
          ]
        },
        { name: "辖区人口（万人）", keys: "jurisdictionPopulation" },
        { name: "对所人员人均管辖人口", keys: "teamJurisdictionPopulation" },
        {
          name: "辖区持证户数（户）",
          keys: "jurisdictionCertifiedAccountTotal"
        },
        {
          name: "对所人员人均管辖户数（户）",
          keys: "teamJurisdictionAveragePopulation"
        },
        { name: "执法记录仪数量（个）", keys: "bodyCameraNum" }
      ],
      statisticsColumn12313: [
        { name: "单位", keys: "orgName" },
        {
          name: "专卖",
          list: [
            { name: "政策法规", keys: "governmentalPolicy" },
            { name: "许可咨询", keys: "licenseConsultation" },
            { name: "真假鉴别", keys: "truefalseIdentification" },
            { name: "电子烟", keys: "electronic" }
          ]
        },

        {
          name: "营销",
          list: [
            { name: "证件举报", keys: "licComplaints" },
            { name: "真假烟举报", keys: "authenticCigarettesComplaints" },
            { name: "未成年人保护", keys: "protectionOfMinors" },
            { name: "投诉", keys: "complaints" },
            { name: "卷烟代订", keys: "cigaretteOrdering" },
            { name: "客户基础信息", keys: "customerBasicInformation" },
            { name: "货源供应", keys: "supplyOfGoods" },
            { name: "终端建设", keys: "terminalConstruction" },
            { name: "结算服务", keys: "settlementService" },
            { name: "卷烟价格", keys: "cigarettePrices" },
            { name: "经营投诉", keys: "businessComplaints" }
          ]
        },
        {
          name: "物流",
          list: [
            { name: "物流送货", keys: "logisticsDelivery" },
            { name: "物流投诉", keys: "logisticsComplaints" }
          ]
        },
        {
          name: "工业",
          list: [{ name: "卷烟质量", keys: "cigaretteQuality" }]
        }
      ]
      // LicenceNewList=[]
    };
  },
  onLoad() {
    this.param = this.getRouteParam();
    this.handleProc = this.param.reportCode;
    console.log(this.getRouteParam(), "this.getRouteParam()");
    this.whosType = this.handleProc;
    switch (this.handleProc) {
      case "lic_handle_count_hb":
        this.statisticsColumn = this.statisticsColumnLicence;
        this.titleTJ = "许可证办理统计";
        this.getStatisticsLicence();
        break;
      case "LIC_TEAM_BUILDING_STATISTICS":
        this.statisticsColumn = this.statisticsColumnTeambuild;
        this.titleTJ = "队伍建设统计表";
        this.getStatisticsTeambuild();
        break;
      case "LIC_12313_STATISTICS":
        this.statisticsColumn = this.statisticsColumn12313;
        this.titleTJ = "12313统计表";
        this.getStatistics12313();
        break;
      default:
        break;
    }
  },
  methods: {
    getListViewHeight() {
      let p =
        this.$u.sys().windowHeight -
        44 -
        uni.upx2px(180) -
        this.$u.sys().statusBarHeight +
        "px";
      return p;
    },
    //许可证办理统计
    getStatisticsLicence() {
      uni.showLoading({
        title:'加载中...',
      });
      reportService
        .LicenceStatisticsCom({ reportCode: "lic_handle_count_hb" })
        .then(res => {
          if (res.success) {
            this.newList = res.data[0].commonDetailList;
            uni.hideLoading();
          } else {
            this.$u.error(res.msg);
            uni.hideLoading();
          }
        })
        .catch(err => {
          this.$u.error(err.msg);
          uni.hideLoading();
        });
    },
    //队伍建设
    getStatisticsTeambuild() {
      uni.showLoading({
        title:'加载中...',
      });
      reportService
        .LicenceStatisticsCom({ reportCode: "LIC_TEAM_BUILDING_STATISTICS" })
        .then(res => {
          if (res.success) {
            this.newListTeambuild = res.data[0].commonDetailList;
            uni.hideLoading();
          } else {
            this.$u.error(res.msg);
            uni.hideLoading();
          }
        })
        .catch(err => {
          this.$u.error(err.msg);
          uni.hideLoading();
        });
    },
    getStatistics12313() {
      uni.showLoading({
        title:'加载中...',
      });
      reportService
        .LicenceStatisticsCom({ reportCode: "LIC_12313_STATISTICS" })
        .then(res => {
          if (res.success) {
            this.newList12313 = res.data[0].commonDetailList;
            uni.hideLoading();
          } else {
            this.$u.error(res.msg);
            uni.hideLoading();
          }
        })
        .catch(err => {
          this.$u.error(err.msg);
          uni.hideLoading();
        });
    }
  }
};
</script>
<style lang="scss" scoped>
.static {
  width: 100%;
  height: 160rpx;
  color: #fff;
  display: flex;
  padding: 30rpx 40rpx;
  margin-bottom: 40rpx;
  align-items: center;
  justify-content: space-between;
  background-color: #327be7;
  .text {
    font-size: 36rpx;
  }
  .num {
    font-size: 50rpx;
    font-weight: 700;
  }
  .unit {
    font-size: 30rpx;
  }
}
.u-table-wrap {
  overflow-x: auto;
  max-width: 100%;
  .table-unit {
    font-size: 24rpx;
    text-align: right;
    margin-top: 20rpx;
  }
  /deep/ .u-table {
    overflow-x: scroll;
    width: 100%;
    .u-tr {
      width: max-content;
      .u-td {
        background-color: #fff;
      }
      .u-th,
      .u-td {
        width: 200rpx;
        position: static;
        z-index: 0;
        flex: auto;
        .u-th {
          &:last-child {
            border-right: 0 !important;
          }
        }
      }
    }
    // --勿动，慎改--
    .u-tr .u-td:first-child,
    .u-tr .u-th:first-child {
      position: sticky;
      left: 0;
      z-index: 1;
    }
    .col-th {
      position: sticky;
      left: 0;
      z-index: 1;
    }
    .col-th1 {
      width: auto !important;
    }
    // --勿动，慎改--
  }
}
.no-data{
	text-align: center;margin: 20px;
}
</style>